package com.bluesea.report.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.bluesea.report.entity.Integral;
import com.bluesea.report.service.integral.impl.IntegralServiceImpl;

@Controller
@RequestMapping("/integral")
public class IntegralController {
	
	@Autowired
	private IntegralServiceImpl integralServiceImpl;

	/**
	 * 无条件查询，查询全部数据
	 * @return
	 */
	@RequestMapping(value = "/getIntegralAll", method=RequestMethod.GET)
	@ResponseBody
	public String getMenuAll() {
		List<Integral>integralList = new ArrayList<Integral>();
		try {
			integralList = integralServiceImpl.getIntegralAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return JSONArray.toJSONString(integralList);
	}
	
	/**
	 * 条件查询
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "/query", method = RequestMethod.POST)
	public String query(@RequestBody Map<String, Object> params) {
		List<Integral>integralList = new ArrayList<Integral>();
		try {
			integralList = integralServiceImpl.query(params);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return JSONArray.toJSONString(integralList);
	}
}
